package com.xyb.controller;

import com.xyb.config.exception.MyException;
import com.xyb.entity.PageResult;
import com.xyb.entity.StatusCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
public class TestController {

    public void t(){
        System.out.println("t");
    }

    @GetMapping("t0")
    public void t0() {

    }

    @GetMapping("t1")
    public String t1() {
        return "abc";
    }

    @GetMapping("t2")
    public List<String> t2() {
        return Arrays.asList("1", "2");
    }

    @GetMapping("t3")
    public Integer t3(Integer a) {
        if (a == 1) {
            throw new MyException("我是自定义");//能够构造器里使用
        }
        if (a == 2) {
            throw new MyException(StatusCode.USER_NOT_EXIST);//能够构造器里使用
        }
        return 102;
    }

    @GetMapping("t4")
    public PageResult<String> t4() {
        return PageResult.result(344739147160346624L,Arrays.asList("1","2"));
    }

    @GetMapping("t5")
    public PageResult<String> t5() {
        return PageResult.result(Arrays.asList("111","222"));
    }
}
